# statistics 

from datetime import datetime


MAX_EPOCH = "17:38 02 Aug 2011" 

def build(d_f, d_w, d_p, d_u):
	
	# epoch
	epoch = datetime.strptime(MAX_EPOCH, "%H:%M %d %b %Y")

	# last 
	last_feeding = d_f[-1]
	last_wet = d_w[-1]
	last_poopy = d_p[-1]
	last_unknown = d_u[-1]

	# totals
	total_all_needs = len(d_f) + len(d_w) + len(d_p) + len(d_u)
	total_feedings = len(d_f)
	total_wet = len(d_w)
	total_poopy = len(d_p)
	total_unknown = len(d_u)

	return {"epoch": epoch, 
		"last_feeding": rs(str(last_feeding)),
		"last_wet": rs(str(last_wet)),
		"last_poopy": rs(str(last_poopy)),
		"last_unknown": rs(str(last_unknown)),
		"total_all_needs": rs(str(total_all_needs)),
		"total_feedings": rs(str(total_feedings)),
		"total_wet": rs(str(total_wet)),
		"total_poopy": rs(str(total_poopy)),
		"total_unknown": rs(str(total_unknown))}

def rs(s):
	return ':'.join(str(s).split(':')[:2])
